package main

import (
	"jvm/rtda"
)

func main() {
	cmd := parseCmd()
	// if cmd.versionFlag {
	// 	fmt.Println("version 0.0.1")
	// } else if cmd.helpFlag || cmd.class == "" {
	// 	printUsage()
	// } else {
	startJVM(cmd)
	// }

}
func startJVM(cmd *Cmd) {
	frame := rtda.NewFrame(100, 100)
	testLocalVars(frame.LocalVars())
	testOperandStack(frame.OPStack())

}
func testLocalVars(vars rtda.LocalVars) {
	vars.SetInt(0, 100)
	vars.SetInt(1, -100)
	vars.SetLong(2, 2997924580)
	vars.SetLong(4, -2997924580)
	vars.SetFloat(6, 3.1415926)
	vars.SetDouble(7, 2.71828182845)
	vars.SetRef(9, nil)
	println(vars.GetInt(0)) //100
	println(vars.GetInt(1)) //-100
	println(vars.GetLong(2)) //2997924580
	println(vars.GetLong(4)) //-2997924580
	println(vars.GetFloat(6)) //3.1415926
	println(vars.GetDouble(7)) //2.71828182845
	println(vars.GetRef(9)) //nil
}
func testOperandStack(ops *rtda.OPStack) {
	ops.PushInt(100)
	ops.PushInt(-100)
	ops.PushLong(2997924580)
	ops.PushLong(-2997924580)
	ops.PushFloat(3.1415926)
	ops.PushDouble(2.71828182845)
	ops.PushRef(nil)
	println(ops.PopRef())
	println(ops.PopDouble())
	println(ops.PopFloat())
	println(ops.PopLong())
	println(ops.PopLong())
	println(ops.PopInt())
	println(ops.PopInt())
}
